<!--partner_customer_list-->
<style>
.custom-shape img {
  width: 80%;
}
.custom-shape-radio label {
  display: block;
  overflow: hidden;
  margin-bottom: .8em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table input[type=radio] {
  margin: 0 0.3em;
}
.customer-research{
  width: 50%;
}
.customer-research td{
  white-space: nowrap;
  padding: 0 .5em;
}
.search-list {
  margin: 2em 0;
  text-align: center;
}
.search-list tr{
  border-bottom: 1px solid #e3e3e3;
}
.search-list th{
  background-color: #e8e9eB;
  font-weight: normal;
}
.new-customer-popup {
  height: 600px;
  padding: 0;
}
.new-customer-popup .partner-title {
  margin-top: 0;
}
</style>
<div class="heading"><strong><?php echo L('customer_list');?></strong></div>
<div class="clearfix">
  <div class="pull-left">
    <span class="btn js-add-customer"><?php echo L('add_customer');?></span>
  </div>
  <form name="searchForm" action="<?php echo url('partner/customer');?>" method="post">
    <table class="pull-right customer-research">
      <tr>
        <td>
          <select name="searchType">
            <option value="email" <?php if($searchType == 'email'):?>selected<?php endif;?>><?php echo L('_email_');?></option>
            <option value="name"  <?php if($searchType == 'name'):?>selected<?php endif;?>><?php echo L('_name_');?></option>
            <option value="phone" <?php if($searchType == 'phone'):?>selected<?php endif;?>><?php echo L('phone');?></option>
          </select>
        </td>
        <td><input type="text" name="keywords" value="<?php echo $keywords;?>" /></td>
        <td><span class="btn search-customer-list"><?php echo L('search');?></span></td>
      </tr>
    </table>
  </form>
</div>
<table class="search-list">
  <tr>
    <th><?php echo L('_email_');?></th>
    <th><?php echo L('_name_');?></th>
    <th><?php echo L('_addtime_');?></th>
    <th><?php echo L('orderNumber');?></th>
    <th><?php echo L('orderTotalAmount');?></th>
    <th><?php echo L('phone');?></th>
    <th><?php echo L('_ACTION_');?></th>
  </tr>
  <?php foreach($addressList as $address):?>
  <tr>
    <td><?php echo $address['delivery_email'];?></td>
    <td><?php echo $address['delivery_first_name'].' '.$address['delivery_last_name'];?></td>
    <td><?php echo date('d/m/Y',$address['start_time']);?></td>
    <td><?php echo $address['order_count'];?></td>
    <td><?php echo currency($address['order_amount']);?></td>
    <td><?php echo $address['delivery_phone'];?></td>
    <td>
      <a href="<?php echo url('partner/customer_detail',array('addrid'=>$address['id']));?>" class="link"><?php echo L('CHECK')?></a> |
      <a href="<?php echo url('partner/order_add',array('addrid'=>$address['id']));?>" class="link"><?php echo L('NEW_ORDER')?></a>
    </td>
  </tr>
  <?php endforeach;$address = NULL;?>
</table>
<div class="align-right">
  <span class="pageTurn"><?php echo $pageShow;?></span>
</div>
<template class="customer-info-template">
  <?php include THEMES_PATH . 'partner/partner_create_customer.phtml';?>
  <input type="hidden" name="dosubmit" value="1">
  <div class="mt2x align-center">
    <button type="submit" class="mr1x btn js-customer-submit">确认</button>
    <button type="button" class="btn js-customer-cancel">取消</button>
  </div>
</template>
<script>
$(function () {
  $('.js-add-customer').popupBox({
    quickClose: true,
    content: function() {
      var _formHtml = '<form action="<?php echo __SELF__;?>" name="create" class="js-order-add-form" method="post">' + $(".customer-info-template").html() + '</form>';
      return _formHtml;
    },
    beforeShow: function (trigger, popupBox) {
      popupBox.addClass('new-customer-popup js-new-customer-popup');
    },
    afterShow: function () {
      $('.js-order-add-form').validate({
        errorElement: 'p',
        submitHandler: function (form) {
          form.submit();
        },
        errorPlacement: function (error, element) {
          element.after(error);
        },
        rules: {
          delivery_email: {
            required: true,
            email: true
          }
        },
        messages: {
          delivery_email: {
            required: "<?php echo L('input_email_addres');?>",
            email: "<?php echo L('_EMAIL_FORMAT_ERROR_');?>"
          }
        }
      });
    }
  });

  $('body').on('click', '.js-customer-cancel', function () {
    $('.js-new-customer-popup').find('.js-close').trigger('click');
  });

  /*搜索*/
  $('.search-customer-list').bind('click', function () {
    var keywords = $('form[name=searchForm]').find('input[name=keywords]').val();
    if(keywords != ''){
      $('form[name=searchForm]').submit();
    }
  });
});
</script>